using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace SemanticDiscovery.Util.String
{
  public static class ExtensionMethods {

    // todo: 
    // throw System.ArgumentOutOfRangeException:
    //   negative length or start
    //   start + len > last idx of string
    public static string Slice(this string str, int start, int end) {
      int len = end - start;
      return str.Substring(start, len);
    }

    public static string RemoveWhitespace(this string str) {
      StringBuilder builder = new StringBuilder();

      foreach(char ch in str.ToCharArray()) {
        if(!Char.IsWhiteSpace(ch)) {
          builder.Append(ch);
        }
      }

      return builder.ToString();
    }

  }
}
